using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ConfigData
{
    public partial class FormConfigData : Form
    {
        string sourcefile, destFile;
        bool allowClose = false;

        public FormConfigData(string sourcePath)
        {
            InitializeComponent();

            this.sourcefile = sourcePath;
        }

        public string DestPath
        {
            get { return destFile; }
            set { destFile = value; }
        }

        public string Sourcefile
        {
            get { return sourcefile; }
            set { sourcefile = value; }
        }

        private void buttonSelectPath_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                textBoxPath.Text = folderBrowserDialog1.SelectedPath;
            }
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            destFile = textBoxPath.Text.Trim();
            File.Move(sourcefile + "ConfigData.exe", destFile + "ConfigData.exe");
            allowClose = true;
            this.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            labelSourceFile.Text = sourcefile;
            textBoxPath.Text = destFile;
        }

        private void FormConfigData_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (allowClose == false)
            {
                MessageBox.Show("Skip the step? Yes= Skip ;No= back the windows form", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }
        }
    }
}